import 'package:f_demo_one/views/detail_page.dart';
import 'package:flutter/material.dart';

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          centerTitle: true,
          title: const Text('首页'),
        ),
        body: Container(
            width: double.infinity,
            height: double.infinity,
            decoration: const BoxDecoration(
              color: Color.fromARGB(255, 183, 182, 182),
            ),
            child: Column(
              children: [
                const Text('首页'),
                ElevatedButton(
                    onPressed: () {
                      // 跳转到详情页
                      // ---------------方式一
                      Navigator.push(context,
                          MaterialPageRoute(builder: (context) {
                        return const DetailPage();
                      }));
                    },
                    child: const Text('去详情页-方式一')),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                    onPressed: () {
                      // ---------------方式二
                      Navigator.pushNamed(context, '/detail',
                          arguments: {'id': 1, 'name': '张三'});
                    },
                    child: const Text('去详情页-方式二'))
              ],
            )));
  }
}
